﻿    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lola.Persistencia
{
    public class AdministradorPersistenciaMicro
    {
        private static AdministradorPersistenciaMicro admMi;

        public static AdministradorPersistenciaMicro getInstanciaMicro()
        {
            if (admMi == null)
                admMi = new AdministradorPersistenciaMicro();
            return admMi;
        }
        public Micro buscarMicro(int numint)
        {
            using (SEMINARIOIEntities contextSeminarioI = new SEMINARIOIEntities())
            {
                var query = from p in contextSeminarioI.Micro
                            where p.numInt == numint
                            select p;
                Micro mi = query.First();
                return mi;
            }

        }
        public List<Micro> ObtenerMicrosenSector(String sector, String galpon)
        {
            List<Micro> res = new List<Micro>();
            using (SEMINARIOIEntities contexto = new SEMINARIOIEntities())
            {
                IQueryable lista = from m in contexto.InformeSectors
                                   where m.SectorGalpon.Sector.nomSec.Equals(sector) & m.SectorGalpon.Galpon.nomGal.Equals(galpon)
                                   select m.Servicio.Micro;
                foreach (Micro m in lista)
                {
                    res.Add(m);
                }
            }
            return res;
        }
    }
}
